package ee.mtiidla.data;

import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;

/**
 * Created by Marko on 12.10.2014.
 */
@XmlAccessorType(XmlAccessType.FIELD)
public class Result {

	@XmlAttribute(name = "resultid")
	private long resultId;

	@XmlAttribute(name = "eventid")
	private long eventId;

	@XmlAttribute(name = "heatid")
	private long heatId;

	@XmlAttribute(name = "lane")
	private int lane;

	@XmlAttribute(name = "swimtime")
	private String swimtime;

	@XmlAttribute(name = "entrytime")
	private String entrytime;

	@XmlAttribute(name = "status")
	private String status;

	@XmlAttribute(name = "points")
	private String points;

	@XmlAttribute(name = "comment")
	private String comment;

	@XmlElementWrapper(name="SPLITS")
	@XmlElement(name="SPLIT")
	private List<Split> splits;

	@XmlElementWrapper(name="RELAYPOSITIONS")
	@XmlElement(name="RELAYPOSITION")
	private List<RelayPosition> relayPositions;

	public long getResultId() {
		return resultId;
	}

	public void setResultId(long resultId) {
		this.resultId = resultId;
	}

	public long getEventId() {
		return eventId;
	}

	public void setEventId(long eventId) {
		this.eventId = eventId;
	}

	public long getHeatId() {
		return heatId;
	}

	public void setHeatId(long heatId) {
		this.heatId = heatId;
	}

	public int getLane() {
		return lane;
	}

	public void setLane(int lane) {
		this.lane = lane;
	}

	public String getSwimtime() {
		return swimtime;
	}

	public String getSwimtimeShort() {

		if (swimtime == null) return null;

		String shorter = swimtime;
		while (shorter.startsWith("0") || shorter.startsWith(":")) {
			shorter = shorter.substring(1, shorter.length());
		}
		return shorter;
	}

	public void setSwimtime(String swimtime) {
		this.swimtime = swimtime;
	}

	public String getEntrytime() {
		return entrytime;
	}

	public void setEntrytime(String entrytime) {
		this.entrytime = entrytime;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getPoints() {
		return points;
	}

	public void setPoints(String points) {
		this.points = points;
	}

	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	public List<Split> getSplits() {
		return splits;
	}

	public void setSplits(List<Split> splits) {
		this.splits = splits;
	}

	public List<RelayPosition> getRelayPositions() {
		return relayPositions;
	}

	public void setRelayPositions(List<RelayPosition> relayPositions) {
		this.relayPositions = relayPositions;
	}
}
